// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import FastClick from 'fastclick'
import VueRouter from 'vue-router'
import App from './App'
// import Home from './components/HelloFromVux'
import routes from './router/index'
import './common/commons'
import store from './vuex/store'
import './directives/directives'
import './filters/filters'
import Vuex from 'vuex';
import './ajax/ajax'

Vue.use(VueRouter)
Vue.use(Vuex)

// const routes = [{
//   path: '/',
//   component: Home
// }]

const router = new VueRouter({
  routes
});
let isLogin = true;

// 路由守卫，拦截未登录的url
router.beforeEach((to, from, next) => {
  if (to.matched.some(record => record.meta.requiresAuth)) {
    if (!isLogin) {
      next({
        path: '/home',
        query: { redirect: to.fullPath }
      })
    } else {
      next()
    }
  } else {
    next()
  }
})

FastClick.attach(document.body)

Vue.config.productionTip = false

/* eslint-disable no-new */
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app-box')
